Online documentation - WebsydianExpress v3.5 |
This document describes the RRN (Relative Record Number)based blockfetch functions WsyStatelessBlockFetch and BlockFetchRRNWrapper.
The Ext JS framework for WebsydianExpress has a grid load functionality that differs significantly from standard Websydian.
One of the differences is the way the page can request more data for a grid. This document will describe the old and the new behavior - and the way you must create or wrap your BlockFetch functions to handle the behavior expected by the Ext JS framework.
In standard Websydian, this is done by having a "Next" event, that received the keys for the last record shown on the page in WebInput. The EventHandler would then call the PageGenerator with this information, and the PageGenerator would call the BlockFetch with the same information.
This functionality is easily mapped to a standard BlockFetch function as these functions already are designed for receiving the Position as key fields in an input variable.
The Ext JS frame work for WebsydianExpress also has an EventHandler that is called when more data should be retrieved for the grid. This is the LoadData EventHandler that is scoped by all PageGenerators that inherits from ExtWebGridPage.
This EventHandler does not receive the key for the last record shown - instead it receives two parameters ExtStartRecord and EXTLimit.
ExtStartRecord is the row number of the next record to show, while ExtLimit is the number of records to retrieve.
So if you have loaded 64 records to the grid, and want to fetch 64 more, you will get a value of 65 for ExtStartRecord and a value of 64 for ExtLimit.
The grid component that is loaded for the grid page sends the requests with this information automatically, either when the grid is initially loaded, or when the user scrolls down, and the control finds that more data is needed.
To avoid cluttering the WebInput variable with these fields, a special variable SysWebInput has been created to hold these data from the request (and other grid relevant data for future use).
SysWebInput is populated in the same way as the WebInput variable - by retrieving the fields from the HTTP request parameters.
The problem is that a standard BlockFetch function is not designed to receive a record number for positioning the list of data to retrieve - it expects key values. This leads to the need for abstract functions that is able to receive the record number as input, and return the next set of data based on this information.
It is important to note that the RRN BlockFetch functions behave like the StatelessBlockFetch functions.
This means that the view used must have a unique key and that you must specify the original Position value on each call (even though Control<Position> = Yes).
The RRN BlockFetch functions has a field "RelativeRecordNumber" in the Position input variable in addition to the normal key fields from the view. This RelativeRecordNumber is the start record to fetch (corresponds to ExtStartRecord described above).
The BlockFetch will start by positioning using the key fields, then it will read/count through the records until it has read the number of records specified by the RelativeRecordNumber - then it will start populating the FetchedData multi occurrence output variable - just like any other BlockFetch.
This example will show how the RRN functionality works for the following Country Records - the records are sorted by Country Name followed by ID:
Name | ID |
Albania | 4 |
Belize | 13 |
Cuba | 14 |
Denmark | 1 |
Estonia | 9 |
Finland | 2 |
Germany | 15 |
Hungary | 8 |
Iceland | 3 |
Jamaica | 10 |
Korea | 11 |
Laos | 6 |
Mongolia | 12 |
Nepal | 5 |
Oman | 16 |
Russia | 7 |
If the RRN BlockFetch function has an occurrence of 5 for the FetchedData variable, and it is called with the Position parameters:
Name: E, ID = 0, RelativeRecordNumber = 0 - the following records will be retrieved:
Name | ID |
Estonia | 9 |
Finland | 2 |
Germany | 15 |
Hungary | 8 |
Iceland | 3 |
To retrieve the next block of data, the following parameters will be specified:
Name: E, ID = 0, RelativeRecordNumber = 6 - the following records will be returned:
Name | ID |
Jamaica | 10 |
Korea | 11 |
Laos | 6 |
Mongolia | 12 |
Nepal | 5 |
Here it is important to understand that if you had not specified the value for the name, the output would have been different:
Name = , ID = 0, RelativeRecordNumber = 6 - the following records would have been returned (as Finland is the sixth record from the top of the complete view):
Name | ID |
Finland | 2 |
Germany | 15 |
Hungary | 8 |
Iceland | 3 |
Jamaica | 10 |
In WSYBASE, you can find two entities, that scope RRN BlockFetch functions: DataAccessRRN, and RRNEntityRelationalTable
The BlockFetchRRNWrapper function enables you to use existing BlockFetch functions in the Ext JS for WebsydianExpress framework. It is simply a wrapper function that receives the RelativeRecordNumber parameter and the key fields, calls the "normal" BlockFetch function with the key fields, throws the records before the specified relative record number away (makes repeated calls to the existing BlockFetch function if necessary) - and finally returns any records that has a relative record number that is higher than the number specified in the output.
This wrapper function means that you get an additional function - but it does enable you to resuse existing BlockFetch functions.
You can inherit from the WsyStatelessBlockFetch if you are going to implement a new BlockFetch function. This is not a wrapper function, it simply is a standard StatelessBlockFetch function that also supports the handling of the RRN functionality described above.